<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='zbjgl'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <form name="totalForm" id="totalForm" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='zjbid'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="liveID" value="${params.liveID}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='zbjmc'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="liveName" value="${params.liveName}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='zbjms'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="liveIntroduce" value="${params.liveIntroduce}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='zt'/></label>
                    <div class="layui-input-inline">
                        <select name="accountLocked">
                            <option value="0"><fmt:message key='qxz'/></option>
                            <option value="1" <c:if test="${params.accountLocked == 1}">selected</c:if>><fmt:message key='zc'/></option>
                            <option value="2" <c:if test="${params.accountLocked == 2}">selected</c:if>><fmt:message key='jy'/></option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                </div>

            </div>
        </form>
    </div>
</div>

<div class="layui-card">
    <div class="layui-field-box layui-form">

        <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="enables"><i class="layui-icon">&#xe605;</i> <fmt:message key='plqy'/></a>
        <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-danger" id="disables"><i class="layui-icon">&#x1006;</i> <fmt:message key='pljy'/></a>

        <table class="layui-table" lay-size="sm">
            <thead>
            <tr>
                <th width="5%"><input id="checkboxs" type="checkbox" lay-ignore lay-skin="primary"/></th>
                <th><fmt:message key='xh'/></th>
                <th><fmt:message key='xm'/></th>
                <th><fmt:message key='sjh'/></th>
                <th><fmt:message key='zjbid'/></th>
                <th><fmt:message key='zbjtp'/></th>
                <th><fmt:message key='zbjmc'/></th>
                <th><fmt:message key='zbjms'/></th>
                <th><fmt:message key='cjsj'/></th>
                <th><fmt:message key='zt'/></th>
                <th><fmt:message key='cz'/></th>
            </tr>
            </thead>
            <c:forEach items="${page.result}" var="item" varStatus="status">
                <tr>
                    <td>
                        <input type="checkbox" lay-ignore value="${item.id}" class="feijin-check" lay-skin="primary"/>
                    </td>
                    <td>${status.index + 1}</td>
                    <td>${item.realName}</td>
                    <td>${item.mobile}</td>
                    <td>${item.liveID}</td>
                    <td><img src="${store_domain}/uploads/${item.liveImage}" class="preview" style="max-height: 150px"></td>
                    <td>${item.liveName}</td>
                    <td>${item.liveIntroduce}</td>
                    <td><fmt:formatDate value="${item.liveCreateTime}" type="both"/></td>
                    <td>
                        <c:if test="${item.accountNonLocked}"><fmt:message key='zc'/></c:if>
                        <c:if test="${!item.accountNonLocked}"><fmt:message key='jy'/></c:if>
                    </td>
                    <td>
                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='xq'/></a>
                        <c:if test="${item.accountNonLocked}">
                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs locked"><fmt:message key='jy'/></a>
                        </c:if>
                        <c:if test="${!item.accountNonLocked}">
                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs unlocked"><fmt:message key='qy'/></a>
                        </c:if>
                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-remove"><fmt:message key='sc'/></a>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <jsp:include page="/commons/page.jsp" flush="true"/>
    </div>
</div>

<script>
    layui.use("layer", function () {

        var layer = layui.layer;

        //删除
        $(".feijin-remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrscm?'/>", function () {
                feijin.delete({
                    url: "${web_domain}/live/remove",
                    data: {"id": id}
                });
            });
        })

        //查看
        $(".feijin-detail").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2
                , title: '<fmt:message key='xq'/>'
                , content: '${web_domain}/live/detail?id=' + id
                , maxmin: true
                , area: ['90%', '90%']
                , btn: ['<fmt:message key='fh'/>']
            });
        });

        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });

        //批量启用账号
        $("#enables").click(function () {
            var ids = [];

            $(".feijin-check:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }

            layer.open({
                content: '<fmt:message key='qryjxzdzbjqbqym?'/>'
                , btn: ['<fmt:message key='qy'/>', '<fmt:message key='qx'/>']
                , yes: function () {
                    $.ajax({
                        url: "${web_domain}/mall/member/enables",
                        type: "post",
                        dataType: "json",
                        data: {
                            "ids": ids.join(";"),
                            "_method": "put"
                        },
                        success: function (result) {
                            if (result.status) {
                                location.reload();
                            }
                        }
                    });
                }
            });
        });

        //批量禁用账号
        $("#disables").click(function () {
            var ids = [];

            $(".feijin-check:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }

            layer.open({
                content: '<fmt:message key='qryjxzdzbjqbjym?'/>'
                , btn: ['<fmt:message key='jy'/>', '<fmt:message key='qx'/>']
                , yes: function () {
                    $.ajax({
                        url: "${web_domain}/mall/member/disables",
                        type: "post",
                        dataType: "json",
                        data: {
                            "ids": ids.join(";"),
                            "_method": "put"
                        },
                        success: function (result) {
                            if (result.status) {
                                location.reload();
                            }
                        }
                    });
                }
            });
        });

        //禁用
        $(".feijin-locked").click(function () {
            var id = $(this).attr("data-id");
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 0,
                    title: '<fmt:message key='jyzh'/>',//自定义标题样式
                    border: [0],
                    content: '<span class="orange"><fmt:message key='jyhgzhjwfdl,qrjyzhm?'/></span>',
                    btn: ['<fmt:message key='jy'/>', '<fmt:message key='qx'/>'],
                    yes: function () {
                        $.ajax({
                            type: "post",
                            url: "${web_domain}/mall/member/disable",
                            dataType: "json",
                            data: {
                                "id": id,
                                "_method": "put"
                            },
                            success: function () {
                                location.reload();
                            }
                        });
                    },
                    no: function () {
                        layer.close(index);
                    }
                });
            });
        });

        //启用
        $(".feijin-unlocked").click(function () {
            var id = $(this).attr("data-id");
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.open({
                    type: 0,
                    title: '<fmt:message key='qyzh'/>',
                    border: [0],
                    content: '<span class="orange"><fmt:message key='qdhfgzhzcsym?'/></span>',
                    btn: ['<fmt:message key='qy'/>', '<fmt:message key='qx'/>'],
                    yes: function () {
                        $.ajax({
                            type: "post",
                            url: "${web_domain}/mall/member/enabled",
                            dataType: "json",
                            data: {
                                "id": id,
                                "_method": "put"
                            },
                            success: function () {
                                location.reload();
                            }
                        });
                    },
                    no: function () {
                        layer.close(index);
                    }
                });
            });
        });


    });
</script>
</body>
</fmt:bundle>
</html>
